<?php

namespace App\HttpController;

use App\Service\SensitiveService;
use App\Service\ShareService;
use App\Service\StaffService;
use App\Utility\Verification;
use EasySwoole\HttpAnnotation\AnnotationTag\Api;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiDescription;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiGroup;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiSuccess;
use EasySwoole\HttpAnnotation\AnnotationTag\Method;
use EasySwoole\HttpAnnotation\AnnotationTag\Param;
use EasySwoole\ORM\Exception\Exception;
use Throwable;

/**
 * @ApiGroup(groupName="邻享")
 */
class Share extends BaseController
{
    /**
     * @Api(name="获取格子铺分类", path="/share/getTopic", version="1.0.0")
     * @ApiDescription(value="获取格子铺分类")
     * @Method(allow={POST})
     * @Param(name="limit", defaultValue=10, description="单页数量", from={JSON})
     * @Param(name="page", defaultValue=1, description="页数", from={JSON})
     * @ApiSuccess({"code": 200,"result": [{"id": 3,"name": "记一件小事","icon": "https://s4.ax1x.com/2022/03/03/bYsHaV.png","image": "https://s4.ax1x.com/2022/03/03/bYsHaV.png","description": "","is_deleted": 0,"create_time": 0,"update_time": 0}],"msg": "获取成功"})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getTopic($limit, $page): bool
    {
        $res = ShareService::getInstance()->getTopic($limit, $page);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="共享课堂信息提交", path="/share/schoolJoin", version="1.0.0")
     * @ApiDescription(value="共享课堂信息提交")
     * @Method(allow={POST})
     * @Param(name="nid", description="项目id", required="", from={JSON})
     * @Param(name="house", description="房屋", required="", from={JSON})
     * @Param(name="child_name", description="儿童姓名", required="", notEmpty="孩子姓名不能为空", from={JSON})
     * @Param(name="child_grade", description="儿童班级", required="",  from={JSON})
     * @Param(name="child_hobby", description="儿童爱好", required="", from={JSON})
     * @Param(name="child_age", description="儿童年龄", required="", notEmpty="孩子年龄不能为空", from={JSON})
     * @Param(name="name", description="联系人姓名", required="", notEmpty="联系人姓名不能为空", from={JSON})
     * @Param(name="tel", description="联系方式", required="", notEmpty="联系方式不能为空", from={JSON})
     * @Param(name="name1", description="临时姓名", from={JSON})
     * @Param(name="tel1", description="临时电话", from={JSON})
     * @Param(name="start_time", description="开始时间", required="", from={JSON})
     * @Param(name="end_time", description="结束时间", required="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function schoolJoin($nid, $house, $child_name, $child_grade, $child_hobby, $child_age, $name, $tel, $name1, $tel1, $start_time, $end_time): bool
    {
        $data = $this->request()->getBody()->__toString();
        $check = SensitiveService::getInstance()->verify($data);
        if (!$check['result']) {
            return $this->writeJsonError($check['msg']);
        }
        $checkPhone = Verification::getInstance()->is_phone($tel);
        if (!$checkPhone){
            return $this->writeJsonError('手机号输入错误');
        }
        $checkPhone = Verification::getInstance()->is_phone($tel1);
        if (!$checkPhone){
            return $this->writeJsonError('手机号2输入错误');
        }
        $res = ShareService::getInstance()->schoolJoin($this->uid, $nid, $house, $child_name, $child_grade, $child_hobby, $child_age, $name, $tel, $name1, $tel1, $start_time, $end_time);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="共享养老信息提交", path="/share/oldJoin", version="1.0.0")
     * @ApiDescription(value="共享养老信息提交")
     * @Method(allow={POST})
     * @Param(name="nid", description="项目id", required="", from={JSON})
     * @Param(name="house", description="房屋", required="", from={JSON})
     * @Param(name="older_name", description="老人姓名", required="", notEmpty="老人姓名不能为空", from={JSON})
     * @Param(name="older_age", description="老人年龄", required="", notEmpty="老人年龄不能为空", from={JSON})
     * @Param(name="older_sex", description="老人性别", required="", notEmpty="老人性别不能为空", from={JSON})
     * @Param(name="name", description="联系人姓名", required="", notEmpty="联系人姓名不能为空", from={JSON})
     * @Param(name="tel", description="联系方式", required="", notEmpty="联系方式不能为空", from={JSON})
     * @Param(name="start_time", description="开始时间", required="", from={JSON})
     * @Param(name="end_time", description="结束时间", required="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function oldJoin($nid, $house, $older_name, $older_age, $older_sex, $name, $tel, $start_time, $end_time): bool
    {
        $data = $this->request()->getBody()->__toString();
        $check = SensitiveService::getInstance()->verify($data);
        if (!$check['result']) {
            return $this->writeJsonError($check['msg']);
        }
        $checkPhone = Verification::getInstance()->is_phone($tel);
        if (!$checkPhone){
            return $this->writeJsonError('手机号输入错误');
        }
        $res = ShareService::getInstance()->oldJoin($this->uid, $nid, $house, $older_name, $older_age, $older_sex, $name, $tel, $start_time, $end_time);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取共享工具配置", path="/share/getTools", version="1.0.0")
     * @ApiDescription(value="获取共享工具")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getTools(): bool
    {
        $res = ShareService::getInstance()->getTools();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="共享工具借用", path="/share/toolBorrow", version="1.0.0")
     * @ApiDescription(value="共享工具借用")
     * @Method(allow={POST})
     * @Param(name="nid", description="工具id", required="工具不可为空", from={JSON})
     * @Param(name="tools", description="工具名称", required="工具不可为空", from={JSON})
     * @Param(name="address", description="地址", required="地址不可为空", from={JSON})
     * @Param(name="name", description="联系人", required="姓名不可为空", from={JSON})
     * @Param(name="tel", description="联系方式", required="电话不可为空", from={JSON})
     * @Param(name="start_time", description="开始时间", required="时间不可为空", from={JSON})
     * @Param(name="end_time", description="结束时间", required="时间不可为空", from={JSON})
     * @Param(name="type", description="提货方式", required="提货方式不可为空", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function toolBorrow($nid, $tools, $address, $name, $tel, $start_time, $end_time, $type): bool
    {
        $data = $this->request()->getBody()->__toString();
        $check = SensitiveService::getInstance()->verify($data);
        if (!$check['result']) {
            return $this->writeJsonError($check['msg']);
        }
        $checkPhone = Verification::getInstance()->is_phone($tel);
        if (!$checkPhone){
            return $this->writeJsonError('手机号输入错误');
        }
        $res = ShareService::getInstance()->toolBorrow($this->uid, $nid, $tools, $address, $name, $tel, $start_time, $end_time, $type);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取厨房工具", path="/share/getKitchenTools", version="1.0.0")
     * @ApiDescription(value="获取厨房工具")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getKitchenTools(): bool
    {
        $res = ShareService::getInstance()->getKitchenTools();
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="共享厨房工具,场地借用", path="/share/kitchenToolBorrow", version="1.0.0")
     * @ApiDescription(value="共享厨房工具，场地借用")
     * @Method(allow={POST})
     * @Param(name="nid", description="工具id", required="工具不可为空", from={JSON})
     * @Param(name="tools", description="工具名称", required="工具不可为空", from={JSON})
     * @Param(name="address", description="地址", defaultValue="物业场地", from={JSON})
     * @Param(name="name", description="联系人", required="姓名不可为空", from={JSON})
     * @Param(name="tel", description="联系方式", required="电话不可为空", from={JSON})
     * @Param(name="start_time", description="开始时间", required="时间不可为空", from={JSON})
     * @Param(name="end_time", description="结束时间", required="时间不可为空", from={JSON})
     * @Param(name="type", description="提货方式", defaultValue="2", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function kitchenToolBorrow($nid, $tools, $address, $name, $tel, $start_time, $end_time, $type): bool
    {
        $data = $this->request()->getBody()->__toString();
        $check = SensitiveService::getInstance()->verify($data);
        if (!$check['result']) {
            return $this->writeJsonError($check['msg']);
        }
        $checkPhone = Verification::getInstance()->is_phone($tel);
        if (!$checkPhone){
            return $this->writeJsonError('手机号输入错误');
        }
        $res = ShareService::getInstance()->kitchenToolBorrow($this->uid, $nid, $tools, $address, $name, $tel, $start_time, $end_time, $type);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取我的四点半课堂", path="/share/getMySchool", version="1.0.0")
     * @ApiDescription(value="获取我的四点半课堂")
     * @Method(allow={POST})
     * @Param(name="status", description="状态：0.待审核，1.进行中,2.待支付，-1.已取消", defaultValue="99", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getMySchool($status): bool
    {
        $res = ShareService::getInstance()->getMySchool($this->uid, $status);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取我的共享养老", path="/share/getMyOlder", version="1.0.0")
     * @ApiDescription(value="获取我的共享养老")
     * @Method(allow={POST})
     * @Param(name="status", description="状态：0.待审核，1.进行中,2.待支付，-1.已取消", defaultValue="99", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getMyOlder($status): bool
    {
        $res = ShareService::getInstance()->getMyOlder($this->uid, $status);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取我的共享厨房", path="/share/getMyKitchen", version="1.0.0")
     * @ApiDescription(value="获取我的共享厨房")
     * @Method(allow={POST})
     * @Param(name="status", description="状态：0.待审核，1.进行中,2.待支付，-1.已取消", defaultValue="0", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getMyKitchen($status): bool
    {
        $res = ShareService::getInstance()->getMyKitchen($this->uid, $status);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取我的共享工具", path="/share/getMyTools", version="1.0.0")
     * @ApiDescription(value="获取我的共享工具")
     * @Method(allow={POST})
     * @Param(name="status", description="状态：0.待使用，1.借用中,2.已归还，-1.已取消", defaultValue="0", from={JSON})
     * @Param(name="type", description="获取方式：0.物业配送，1.自提", defaultValue="0", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getMyTools($type, $status): bool
    {
        $res = ShareService::getInstance()->getMyTools($this->uid, $type, $status);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="发布闲置")
     * @Api(name="发布闲置", path="/share/release", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="topic", defaultValue="0", description="话题id", from={JSON})
     * @Param(name="from", description="来自", from={JSON})
     * @Param(name="content", description="文字心情", required="", from={JSON})
     * @Param(name="images", description="图片", required="", from={JSON})
     * @Param(name="location", description="所在位置", required="", from={JSON})
     * @Param(name="price", description="价格", required="", from={JSON})
     * @Param(name="contact_type", description="联系方式：0.不显示，1.微信，2.电话", from={JSON})
     * @Param(name="contact", description="联系方式", required="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function release($topic, $from, $content, $images, $price, $contact_type, $contact, $location): bool
    {
        $data = $this->request()->getBody()->__toString();
        $check = SensitiveService::getInstance()->verify($data);
        if (!$check['result']) {
            return $this->writeJsonError($check['msg']);
        }
        if ($contact_type == 2){
            $checkPhone = Verification::getInstance()->is_phone($contact);
            if (!$checkPhone){
                return $this->writeJsonError('手机号输入错误');
            }
        }
        $res = ShareService::getInstance()->release($this->uid, $topic, $from, $content, $images, $price, $contact_type, $contact, $location);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取格子铺", path="/share/getLattice", version="1.0.0")
     * @ApiDescription(value="获取格子铺")
     * @Method(allow={POST})
     * @Param(name="tid", defaultValue=99, description="话题", from={JSON})
     * @Param(name="limit", defaultValue=10, description="单页数量", from={JSON})
     * @Param(name="page", defaultValue=1, description="页数", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getLattice($tid, $page, $limit): bool
    {
        $res = ShareService::getInstance()->getLattice($tid, $page, $limit);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取我的发布", path="/share/getMyRelease", version="1.0.0")
     * @ApiDescription(value="获取我的发布")
     * @Method(allow={POST})
     * @Param(name="limit", defaultValue=10, description="单页数量", from={JSON})
     * @Param(name="page", defaultValue=1, description="页数", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getMyRelease($limit, $page): bool
    {
        $res = ShareService::getInstance()->getMyRelease($this->uid, $limit, $page);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="点赞动态")
     * @Api(name="点赞动态", path="/share/likeDynamic", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="gid", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function likeDynamic($gid): bool
    {
        $res = ShareService::getInstance()->likeDynamic($this->uid, $gid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="查看动态详情")
     * @Api(name="查看动态详情", path="/share/getDynamicDetail", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="gid", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getDynamicDetail($gid): bool
    {
        $res = ShareService::getInstance()->getDynamicDetail($this->uid, $gid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="查看评论")
     * @Api(name="查看动态评论", path="/share/getDynamicComment", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="gid", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getDynamicComment($gid): bool
    {
        $res = ShareService::getInstance()->getDynamicComment($this->uid, $gid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="动态评论")
     * @Api(name="动态评论", path="/share/commentDynamic", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="id", description="评论id", defaultValue=0, from={JSON})
     * @Param(name="gid", description="动态id", required="", notEmpty="", from={JSON})
     * @Param(name="content", description="内容", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function commentDynamic($id, $gid, $content): bool
    {
        $data = $this->request()->getBody()->__toString();
        $check = SensitiveService::getInstance()->verify($data);
        if (!$check['result']) {
            return $this->writeJsonError($check['msg']);
        }
        $res = ShareService::getInstance()->commentDynamic($this->uid, $id, $gid, $content);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="获取邻享四点半课堂详情")
     * @Api(name="获取邻享四点半课堂详情", path="/share/getSchoolDetail", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="id", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getSchoolDetail($id): bool
    {
        $res = ShareService::getInstance()->getSchoolDetail($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="获取邻享共享老人详情")
     * @Api(name="获取邻享共享老人详情", path="/share/getOlderDetail", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="id", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getOlderDetail($id): bool
    {
        $res = ShareService::getInstance()->getOlderDetail($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="获取邻享共享厨房详情")
     * @Api(name="获取邻享共享厨房详情", path="/share/getKitchenDetail", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="id", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getKitchenDetail($id): bool
    {
        $res = ShareService::getInstance()->getKitchenDetail($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="邻享四点半课堂支付")
     * @Api(name="邻享四点半课堂支付", path="/share/paySchool", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="id", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function paySchool($id): bool
    {
        $res = ShareService::getInstance()->paySchool($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="邻享共享养老支付")
     * @Api(name="邻享共享养老支付", path="/share/payOlder", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="id", description="动态id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function payOlder($id): bool
    {
        $res = ShareService::getInstance()->payOlder($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @ApiDescription(value="邻享热门服务")
     * @Api(name="邻享热门服务", path="/share/getServiceItems", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="limit", description="限制数量", defaultValue="2", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function getServiceItems($limit): bool
    {
        $res = ShareService::getInstance()->getServiceItems($limit);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取格子铺物业产品列表", path="/share/getShareLatticeGoods", version="1.0.0")
     * @ApiDescription(value="获取格子铺物业产品列表")
     * @Method(allow={POST})
     * @Param(name="tid", defaultValue=99, description="话题", from={JSON})
     * @Param(name="limit", defaultValue=10, description="单页数量", from={JSON})
     * @Param(name="page", defaultValue=1, description="页数", from={JSON})
     * @return bool
     * @throws \EasySwoole\Mysqli\Exception\Exception
     * @throws Throwable
     * @throws Exception
     */
    public function getShareLatticeGoods($tid, $limit, $page): bool
    {
        $res = ShareService::getInstance()->getShareLatticeGoods($tid, $limit, $page);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取格子铺产品详情", path="/share/getLatticeDetail", version="1.0.0")
     * @ApiDescription(value="获取格子铺产品详情")
     * @Method(allow={POST})
     * @Param(name="id", required="", notEmpty="", description="产品id", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getLatticeDetail($id): bool
    {
        $res = ShareService::getInstance()->getLatticeDetail($id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="格子铺产品创建订单", path="/share/createOrder", version="1.0.0")
     * @ApiDescription(value="格子铺产品创建订单")
     * @Method(allow={POST})
     * @Param(name="id", required="", notEmpty="", description="产品id", from={JSON})
     * @Param(name="name", required="", notEmpty="", description="联系人", from={JSON})
     * @Param(name="tel", required="", notEmpty="", description="联系电话", from={JSON})
     * @Param(name="address", required="", notEmpty="", description="收货地址", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function createOrder($id, $name, $tel, $address): bool
    {
        $ips = $this->request()->getHeaders()['x-real-ip'] ?? [];
        $this->ip = $ips[0] ?? '127.0.0.1';
        $res = ShareService::getInstance()->createOrder($this->uid, $id, $name, $tel, $address, $this->ip);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }

        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="删除格子铺动态", path="/share/delLattice", version="1.0.0")
     * @ApiDescription(value="删除格子铺动态")
     * @Method(allow={POST})
     * @Param(name="id", required="", notEmpty="", description="动态id", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function delLattice($id): bool
    {
        $res = ShareService::getInstance()->delLattice($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }

        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="转让格子铺动态", path="/share/assignLattice", version="1.0.0")
     * @ApiDescription(value="转让格子铺动态")
     * @Method(allow={POST})
     * @Param(name="id", required="", notEmpty="", description="动态id", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function assignLattice($id): bool
    {
        $res = ShareService::getInstance()->assignLattice($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }

        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="格子铺动态获取我的评论", path="/share/getMyComment", version="1.0.0")
     * @ApiDescription(value="格子铺动态获取我的评论")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getMyComment(): bool
    {
        $res = ShareService::getInstance()->getMyComment($this->uid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }

        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="格子铺动态获取我的点赞", path="/share/getMyLike", version="1.0.0")
     * @ApiDescription(value="格子铺动态获取我的点赞")
     * @Method(allow={POST})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getMyLike(): bool
    {
        $res = ShareService::getInstance()->getMyLike($this->uid);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }

        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取格子铺订单列表", path="/share/getLatticeOrder", version="1.0.0")
     * @ApiDescription(value="获取格子铺订单列表")
     * @Method(allow={POST})
     * @Param(name="status", defaultValue="99", description="状态", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getLatticeOrder($status): bool
    {
        $res = ShareService::getInstance()->getLatticeOrder($this->uid, $status);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="获取格子铺订单详情", path="/share/getLatticeOrderDetail", version="1.0.0")
     * @Method(allow={POST})
     * @ApiDescription(value="获取格子铺订单详情")
     * @Param(name="id", description="订单id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function getLatticeOrderDetail($id): bool
    {
        $res = ShareService::getInstance()->getLatticeOrderDetail($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="格子铺搜索内容", path="/share/searchLattice", version="1.0.0")
     * @Method(allow={POST})
     * @ApiDescription(value="格子铺搜索内容")
     * @Param(name="key", description="关键字", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function searchLattice($key): bool
    {
        $res = ShareService::getInstance()->searchLattice($key);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="删除我的四点半课堂", path="/share/delSchool", version="1.0.0")
     * @ApiDescription(value="删除我的四点半课堂")
     * @Method(allow={POST})
     * @Param(name="id", description="id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function delSchool($id): bool
    {
        $res = ShareService::getInstance()->delSchool($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="删除我的共享养老", path="/share/delOld", version="1.0.0")
     * @ApiDescription(value="删除我的共享养老")
     * @Method(allow={POST})
     * @Param(name="id", description="id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function delOld($id): bool
    {
        $res = ShareService::getInstance()->delOld($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="删除我的共享工具", path="/share/delTool", version="1.0.0")
     * @ApiDescription(value="删除我的共享工具")
     * @Method(allow={POST})
     * @Param(name="id", description="id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function delTool($id): bool
    {
        $res = ShareService::getInstance()->delTool($this->uid, $id);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }

    /**
     * @Api(name="删除我的共享厨房", path="/share/delKitchen", version="1.0.0")
     * @ApiDescription(value="删除我的共享厨房")
     * @Method(allow={POST})
     * @Param(name="id", description="id", required="", notEmpty="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     * @throws \EasySwoole\Mysqli\Exception\Exception
     */
    public function delKitchen($id): bool
    {
        $res = ShareService::getInstance()->delKitchen($this->uid, $id);

        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }
}